package tt.dz.egobus.servicemanager.bean;

import tt.dz.egobus.bean.CodeStatus;

import java.io.Serializable;

/**
 * @author Anson
 * @date 17-3-30
 * @name 当前系统所关心的服务号
 * @since 1.0.3
 */
public enum BusinessCode implements CodeStatus, Serializable {
    DAY(100100, "按天数打车"), TIME(100200, "按次数打车"),;

    /**
     * @param businessCode 当前服务号
     * @author Anson
     * @date 17-3-30
     * @name 判断当前服务号是否是一天服务
     * @since 1.0.3
     */
    public static boolean assertDayBusiness(int businessCode) {
        return DAY.getCode() == businessCode;
    }

    /**
     * @param businessCode 当前服务号
     * @author Anson
     * @date 17-3-30
     * @name 判断当前服务号是否是一次服务
     * @since 1.0.3
     */
    public static boolean assertTIMEBusiness(int businessCode) {
        return TIME.getCode() == businessCode;
    }


    public static String getMsg(int code) {
        BusinessCode status = getStatus(code);
        return status == null ? "" : status.getMsg();
    }

    public static BusinessCode getStatus(int code) {
        for (BusinessCode status : BusinessCode.values()) {
            if (status.getCode() == code) {
                return status;
            }
        }
        return null;
    }

    private final int code;
    private final String msg;

    BusinessCode(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }


    @Override
    public String getMsg() {
        return this.msg;
    }

    @Override
    public int getCode() {
        return this.code;
    }


}
